//
//  PersonContentDetailTableViewCell.m
//  XRSquare
//
//  Created by 穆相臣 on 2018/11/16.
//  Copyright © 2018 UaenaMo. All rights reserved.
//

#import "PersonContentDetailTableViewCell.h"

@interface PersonContentDetailTableViewCell ()
{
    UILabel * titleLabel;
    UILabel * contentLabel;
    UIView * line;
}
@end

@implementation PersonContentDetailTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 50, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        titleLabel.textColor = [UIColor colorFromHexCode:@"a3a3a3"];
        [self addSubview:titleLabel];

        contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, ScreenWidth - 70, 20)];
        contentLabel.font = [UIFont systemFontOfSize:15];
        contentLabel.numberOfLines = 0;
        [self addSubview:contentLabel];
        
        line = [[UIView alloc]initWithFrame:CGRectMake(0, 40, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
        
    }
    return self;
}

+(CGFloat)heightWithDetail:(NSString *)detail
{
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth - 70, 20)];
    label.font = [UIFont systemFontOfSize:15];
    label.numberOfLines = 0;
    label.text = detail;
    [label sizeToFit];
    if (label.frame.size.height < 20)
    {
        return 41;
    }
    else
    {
        return label.frame.size.height + 21;
    }
}

-(void)loadData:(NSString *)data title:(NSString *)title
{
    contentLabel.frame = CGRectMake(70, 10, ScreenWidth - 70, 20);
    contentLabel.text = data;
    titleLabel.text = title;
    [contentLabel sizeToFit];
    if (contentLabel.frame.size.height < 20)
    {
        line.frame = CGRectMake(0, 40, ScreenWidth, 1);
    }
    else
    {
        line.frame = CGRectMake(0, 20 + contentLabel.frame.size.height, ScreenWidth, 1);
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
